package System;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class IOTool {
    String path = "D:\\Code\\设计模式\\Class_10\\外观模式\\Asses\\myText.txt";

    public char[] getStringMethed() throws IOException {
        // 创建FileReader对象，读取文件中的内容
        FileReader reader = new FileReader(path);
        char[] ch = new char[100];
        reader.read(ch);
        reader.close();
        return ch;
    }

    public void WriteStringMethed(char[] writeString) throws IOException {
        File file = new File(path);
        // 如果文件不存在，创建文件
        if (!file.exists())
            file.createNewFile();
        // 创建FileWriter对象
        FileWriter writer = new FileWriter(file);
        // 向文件中写入内容
        writer.write(writeString);
        writer.flush();
        writer.close();
    }

}
